<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/header.css" />
	</head>

	<body>

		<header class="mui-bar mui-bar-nav title">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color: white;"></a>
			<a id="link_submit_notice" class="mui-icon mui-icon-right-nav mui-pull-right"
				style="color: white;font-size: 14px;line-height: 27px;">√</a>
			<h1 class="mui-title title-color">公告编写</h1>
		</header>

		<div class="mui-content">
			<div class="mui-input-row">
				<label>标题</label>
				<input id="noticeTitle" type="text" class="mui-input-clear" placeholder="请输入公告标题">
			</div>
			<div class="mui-input-row">
				<textarea rows="23" cols="20" id="txt_notice" style="height: 100%;" placeholder="请进行公告内容编写"></textarea>
			</div>

		</div>

		<script src="../../js/mui.min.js"></script>
		<script src="../../js/app.js"></script>
		<script type="text/javascript">
			mui.init();

			mui.plusReady(function() {
				var teacher = app.getGlobalUserInfo();

				// 获取标题内容
				var noticeTitle = document.getElementById("noticeTitle");

				// 获取公告内容
				var txt_notice = document.getElementById("txt_notice");

				// 绑定提交公告事件
				var link_submit_notice = document.getElementById("link_submit_notice");
				link_submit_notice.addEventListener("tap", function() {
					if (noticeTitle.value != null && txt_notice.value != null) {
						noticeEdit(noticeTitle.value, txt_notice.value, teacher.user_id);
					} else {
						app.showToast("公告标题或内容不能为空！", "success");
					}
				});

			});

			function noticeEdit(n_title, n_content, n_teacher_id) {
				// ?n_title=203040&n_content=203040&n_teacher_id=203040
				mui.ajax(app.serverUrl + "/user/teacher/release_notice?n_title=" + n_title + "&n_content=" + n_content +
					"&n_teacher_id=" + n_teacher_id, {
						data: {},
						dataType: 'json', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						headers: {
							'Content-Type': 'application/json'
						},
						success: function(data) {
							// app.deleteOnlineApplyList();
							// getApplyList();
							app.showToast("上传公告成功！", "success");
							// 打开公告列表页面
							mui.openWindow({
								url: "teacherNotice.html",
								id: "teacherNotice.html",
								extras: {}
							});
						}
					});
			}
		</script>
	</body>

</html>
